﻿using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;

namespace DevelopmentKit.Extensions.MvcContrib
{
    /// <summary>
    /// 权限扩展
    /// </summary>
    public static class HtmlAuthenticationHelper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="html"></param>
        /// <param name="text"></param>
        /// <param name="action"></param>
        /// <param name="controller"></param>
        /// <param name="routeValues"></param>
        /// <param name="htmlAttributes"></param>
        /// <returns></returns>
        public static MvcHtmlString ActionLinkEx(this HtmlHelper html, string text, string action, string controller, object routeValues, object htmlAttributes)
        {
            var userId = int.Parse(html.ViewContext.HttpContext.User.Identity.Name);
            //var isAllowed = IsAllowed(userId, controller, action, "all");

            //if (!isAllowed)
            //{
            //    return new MvcHtmlString("");
            //}
            return html.ActionLink(text, action, controller, routeValues, htmlAttributes);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="html"></param>
        /// <param name="text"></param>
        /// <param name="action"></param>
        /// <param name="controller"></param>
        /// <param name="routeValues"></param>
        /// <param name="htmlAttributes"></param>
        /// <returns></returns>
        public static MvcHtmlString ActionLinkEx(this HtmlHelper html, string text, string action, string controller, RouteValueDictionary routeValues, Dictionary<string, object> htmlAttributes)
        {
            var userId = int.Parse(html.ViewContext.HttpContext.User.Identity.Name);
            //var isAllowed = IsAllowed(userId, controller, action, "all");

            //if (!isAllowed)
            //{
            //    return new MvcHtmlString("");
            //}
            return html.ActionLink(text, action, controller, routeValues, htmlAttributes);
        } 
    }
}